//
//  MarketSearchHeader.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/20.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "MarketSearchHeader.h"

#import "ZMSearchController.h"

#import "BaseNavigationController.h"



@interface MarketSearchHeader ()
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIView *bigBgView;
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bgY;

@end

@implementation MarketSearchHeader

- (void)awakeFromNib{
    [super awakeFromNib];
    
    
    self.bigBgView.backgroundColor = viewBgGrey;
    
    self.bgView.layer.cornerRadius = 18;
    
    self.bgView.layer.masksToBounds = YES;
    
    self.textField.font = MYFONT(16);
}


- (void)setType:(NSString *)type{
    _type = type;
    
    if ([_type isEqualToString:@"3"]) {
//        self.bigBgView.backgroundColor = viewBgGrey;
        
        self.textField.placeholder = @"输入商品名称搜索";
        
        self.bgY.constant = 0;

    } else {
//        self.bigBgView.backgroundColor = [UIColor redColor];
        
        self.textField.placeholder = @"输入文章标题搜索";

        self.bgY.constant = 10;
    }
    
    
}




- (IBAction)btnDidTap:(UIButton *)sender {
    
//    BaseViewController *temp = [[BaseViewController alloc]init];
//
//    BaseNavigationController *nav = [[BaseNavigationController alloc]initWithRootViewController:temp];
//
//    [self.viewController presentViewController:nav animated:YES completion:nil];
//
//    NSLog(@"dfsdfdsfdsfdsf");
    
    
    
//    PYSearchViewController *searchVC = [PYSearchViewController new];
//    searchVC.hotSearches = @[@"Java", @"Python", @"Objective-C", @"Swift", @"C", @"C++", @"PHP", @"C#", @"Perl", @"Go", @"JavaScript", @"R", @"Ruby", @"MATLAB"];
//    searchVC.hotSearchTitle = @"热门标签";
    
    
//    PYSearchViewController *searchViewController = [PYSearchViewController searchViewControllerWithHotSearches:@[@"Java", @"Python", @"Objective-C", @"Swift", @"C", @"C++", @"PHP", @"C#", @"Perl", @"Go", @"JavaScript", @"R", @"Ruby", @"MATLAB"] searchBarPlaceholder:@"输入关键字搜索" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) {
//        // Call this Block when completion search automatically
//        // Such as: Push to a view controller
//        [searchViewController.navigationController pushViewController:[[UIViewController alloc] init] animated:YES];
//
//    }];
    
    
    
    
//    searchVC.searchTextField.font = MYFONT(14);
//
//    searchVC.searchTextField.textColor = colorWith(42, 144, 131);
//    [searchVC.searchTextField setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
//    searchVC.searchBar.tintColor = colorWith(42, 144, 131);
//    searchVC.searchBar.placeholder = @"搜索";
//    searchVC.searchBar.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
//    searchVC.searchHistoryStyle = PYSearchHistoryStyleNormalTag;
//    __weak typeof(searchVC) weakSearchVC = searchVC;
//    searchVC.didSearchBlock = ^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) {
//
////        NSString *str = [searchText stringByReplacingOccurrencesOfString:@" " withString:@""];
//        BaseViewController *vc = [BaseViewController new];
//        vc.title = searchText;
//        [weakSearchVC.navigationController pushViewController:vc animated:YES];
//    };
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 15, 10, 15);
    
    flowLayout.minimumLineSpacing = 10;
    
    flowLayout.minimumInteritemSpacing = 10;
    
    ZMSearchController *temp = [[ZMSearchController alloc]initWithCollectionViewLayout:flowLayout];
    
    temp.type = self.type;
    
    BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:temp];
    
    [self.viewController presentViewController:nav animated:YES completion:nil];
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
